<!DOCTYPE html >
<html>
<head>
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.line.js" ></script>
    
    <title>RGraph demo: A Line chart with a scrolling backgrund image</title>
    
    <meta name="robots" content="noindex,nofollow" />
    <meta name="description" content="A Line chart with a scrolling backgrund image" />
     
</head>
<body>

    <!-- Share buttons -->
    <p style="float: right">
        <script>
            document.write('<a href="" target="_blank" onclick="window.open(\'https://www.facebook.com/sharer/sharer.php?u=http://www.rgraph.net' + location.pathname + '\', null, \'top=50,left=50,width=600,height=368\'); return false"><img src="../images/facebook-large.png" width="200" height="43" alt="Share on Facebook" border="0" title="Visit the RGraph Facebook page" id="facebook_link" /></a>&nbsp;');
            document.write('<a href="https://twitter.com/_rgraph" target="_blank" onclick="window.open(\'https://twitter.com/intent/tweet?text=Check%20out%20this%20demo%20of%20RGraph:%202D/3D%20JavaScript%20charts%20-%20Free%20and%20Open%20Source%20http://www.rgraph.net' + location.pathname + '\', null, \'top=50,left=50,width=700,height=400\'); return false"><img src="../images/twitter-large.png" width="200" height="43" alt="Share on Twitter" border="0" title="Mention RGraph on Twitter" id="twitter_link" /></a>');
        </script>
    </p>


    <h1>A Line chart with a scrolling background image</h1>


    <div id="container" style="overflow: hidden; position: relative; width: 600px; height: 250px;">
        <canvas id="cvs_chart" width="600" height="250" style="position: absolute; top: 0; left: 0; z-index: 1">[No canvas support]</canvas>
    </div>
    
    <style>
        button {
            font-size: 18pt;
            margin: 5px;
            padding: 5px;
        }
    </style>

    <button onclick="img.src = '../images/line-scrolling-background-image1.jpg'">Background1</button>
    <button onclick="img.src = '../images/line-scrolling-background-image2.jpg'">Background2</button>

    <script>
        imgX  = 0;   // Initial start position
        delta = -0.5;  // Amount of pixels to move by
        delay = 50; // Milliseconds in-between frames

        img = new Image();
            img.src            = '../images/line-scrolling-background-image1.jpg';
            img.style.position = 'absolute';
            img.style.top      = '-50px';
            img.style.left     = 0;
            img.style.zIndex   = -1;
            img.style.opacity  = 0.5;
        document.getElementById('container').appendChild(img);



        line = new RGraph.Line({
            id: 'cvs_chart',
            data: [5,4,1,6,8,5,3],
            options: {
                gutterLeft: 50,
                gutterRight: 50,
                linewidth: 5,
                tickmarks: null,
                backgroundGrid: false,
                shadow: false,
                colors: ['#000'],
                labels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
            }
        }).trace();
            

        function drawImage ()
        {
            if (imgX <= 0 - img.width + line.canvas.width || imgX >= 1) {
                delta *= -1;
            }

            img.style.left = imgX + 'px';
            imgX += delta;

            setTimeout(drawImage, delay);
        }
        
        
        setTimeout(drawImage, delay);
    </script>







    <p></p>

    This goes in the documents header:
    <pre class="code">
&lt;script src="RGraph.common.core.js"&gt;&lt;/script&gt;
&lt;script src="RGraph.line.js"&gt;&lt;/script&gt;
</pre>
    
    Put this where you want the chart to show up:
    <pre class="code">
&lt;div id="container" style="overflow: hidden; position: relative; width: 600px; height: 250px;"&gt;
    &lt;canvas id="cvs_chart" width="600" height="250" style="position: absolute; top: 0; left: 0; z-index: 1"&gt;[No canvas support]&lt;/canvas&gt;
&lt;/div&gt;

&lt;style&gt;
    button {
        font-size: 18pt;
        margin: 5px;
        padding: 5px;
    }
&lt;/style&gt;

&lt;button onclick="img.src = '../images/line-scrolling-background-image1.jpg'"&gt;Background1&lt;/button&gt;
&lt;button onclick="img.src = '../images/line-scrolling-background-image2.jpg'"&gt;Background2&lt;/button&gt;
</pre>

    This is the code that generates the chart:
    <pre class="code">
&lt;script&gt;
    imgX  = 0;   // Initial start position
    delta = -0.5;  // Amount of pixels to move by
    delay = 500; // Milliseconds in-between frames

    img = new Image();
        img.src            = '../images/line-scrolling-background-image1.jpg';
        img.style.position = 'absolute';
        img.style.top      = '-50px';
        img.style.left     = 0;
        img.style.zIndex   = -1;
        img.style.opacity  = 0.5;
    document.getElementById('container').appendChild(img);



    line = new RGraph.Line({
        id: 'cvs_chart',
        data: [5,4,1,6,8,5,3],
        options: {
            gutterLeft: 50,
            gutterRight: 50,
            linewidth: 5,
            tickmarks: null,
            backgroundGrid: false,
            shadow: false,
            colors: ['#000'],
            labels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
        }
    }).trace();
        

    function drawImage ()
    {
        if (imgX &lt;= 0 - img.width + line.canvas.width || imgX >= 1) {
            delta *= -1;
        }

        img.style.left = imgX + 'px';
        imgX += delta;

        setTimeout(drawImage, delay);
    }
    
    
    setTimeout(drawImage, delay);
&lt;/script&gt;
</pre>



    


    <p>
        <a href="./">&laquo; Back</a>
    </p>

</body>
</html>